Skip to main content

CellPrint

Wolfram Kernel
Execution environment
Notebook`CellOperations`
Context

Creates a new cell with a given content in a notebook

CellPrint[str_String, opts___] _RemoteCellObj

where str is a text representation of an expression to be inserted into a new cell.

Options

By the default it prints an output Wolfram Language cell after a current parent input cell, but you can override it

"After"

Specifies a RemoteCellObj after which a new cell will be inserted. A sequence patterns are also supported

"Before"

The same as the previous one, but inserts before the given object

"Type"

The default value is "Output"

"Target"

Default is "Notebook". Specifies the target, where a cell will be printed. Possible values

  • "Notebook" or Automatic or Null
  • "Window" or _ projects to a new window

Example

Print a cell after the current one with a date

With[{cell = ResultCell[]},
EventHandler[InputButton[], Function[Null,
CellPrint[ToString[Now, StandardForm], "After"->cell]
]]
]

or print to a new window

cell = CellPrint[ToString[Plot[x,{x,0,1}], StandardForm], "Target"->_];

and then delete it

Delete[cell];